#include <stdio.h>

// 123
void one_two_three()
{
    int a, b, c;

    for (a = 1; a <= 3; a++)
        for(b = 1; b <= 3; b++)
            for (c = 1; c <= 3; c++)
                if (a != b && a != c && b != c)
                    printf("%d%d%d\n", a, b, c);
}

// 1234
void one_two_three_four()
{
    int a, b, c, d;

    for (a = 1; a <= 4; a++)
        for(b = 1; b <= 4; b++)
            for (c = 1; c <= 4; c++)
                for (d = 1 ; d <= 4; d++)
                if (a != b && a != c && a != d && b != c && b != d && c != d)
                    printf("%d%d%d%d\n", a, b, c, d);
}

void main()
{
    one_two_three();
    one_two_three_four();
}
